package com.ztgf.commodity.api.client;

import com.ztgf.commodity.models.dto.CategoryShieldBrandRelationDTO;
import com.ztgf.commodity.models.service.ICategoryShieldBrandRelationService;
import com.ztgf.common.constant.Result;
import com.ztgf.common.enums.CodeEnum;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 分类盾构品牌关系表控制器
 *
 * @author chenyu.wang
 * @Date 2020-06-02 15:11:41
 */

@RestController
@RequestMapping("/api/categoryShieldBrandRelation")
@Slf4j
@Api(value = "CategoryShieldBrandRelationApiController", tags = "分类盾构品牌关系表Api接口")
public class CategoryShieldBrandRelationApiController {

    @DubboReference
    private ICategoryShieldBrandRelationService categoryShieldBrandRelationService;

    @PostMapping("/get")
    @ApiOperation(value = "根据id查找", notes = "根据id查找")
    @ApiImplicitParam(name = "id", value = "id", required = true, paramType = "query", dataType = "Long")
    public Result<CategoryShieldBrandRelationDTO> get(Long id) {
        if (id == null) {
            return new Result<>(CodeEnum.FAIL_100002);
        }
        CategoryShieldBrandRelationDTO dto = categoryShieldBrandRelationService.selectById(id);
        return new Result<>(dto);
    }

    @PostMapping(value = "/queryShieldBrands")
    @ApiOperation(value = "根据分类顶级id查询关系盾构品牌", notes = "根据分类顶级id查询关系盾构品牌")
    @ApiImplicitParam(name = "id", value = "顶级分类id", required = true, paramType = "query", dataType = "Long")
    public Result queryShieldBrands(Long id) {
        if (id == null) {
            return new Result<>(CodeEnum.FAIL_100002);
        }
        return new Result<>(categoryShieldBrandRelationService.queryShieldBrands(id));
    }

}
